package com.example.test2

import android.icu.util.ULocale.getLanguage
import android.os.Bundle
import android.widget.Button
import android.widget.LinearLayout
import android.widget.Spinner
import android.widget.TextView
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.test2.ui.theme.Test2Theme
import com.example.test2.ProgramExpert
import android.graphics.Color



class MyActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        val expert= ProgramExpert()
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        val spinner=findViewById<Spinner>(R.id.spinner)
        val button=findViewById<Button>(R.id.button)
        val textView=findViewById<TextView>(R.id.textView)
        button.setOnClickListener {
            val selectedFeature=spinner.selectedItem.toString()
            textView.text=expert.getLanguage(selectedFeature)
        }
        val dynamicTexts: LinearLayout=findViewById(R.id.dynamic_texts)
        val buttonAddText: Button=findViewById(R.id.button2)
        buttonAddText.setOnClickListener {
            val count=dynamicTexts.childCount+1
            val dynamicText= TextView(this).apply{
                text="this is a new TextView: $count\n"
                textSize=16f
                setBackgroundColor(Color.GRAY)
                setPadding(16,12,16,12)
            }
            dynamicTexts.addView(dynamicText)

        }
    }
}